﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using TpsAutoSurvey_PDA_Version_.SmsModule;
using TpsAutoSurvey_PDA_Version_.Presenter;

namespace TpsAutoSurvey_PDA_Version_.SocketModule
{
    class SocketCommand:CommandCenter
    {
        private PdaClient pda;
        public SocketCommand(SurveyInterface c)
            : base(c)
        {
            pda = new PdaClient();
            //pda.OnMessageCome = new PdaClient.MessageCome(MsgCome);
            
        }

        void MsgCome(string str)
        {
            string[] recive = str.Split(':');
            if (recive.Length < 2)
            {
                return;
            }
            else if (recive[0] == "msg")
            {
                this.comingNumber = recive[1];
                this.OnMsgRecieved(recive[2],recive[1]);
            }
            else
            {
                SendBackMsg("不被识别的命令!",comingNumber);
            }

        }

 

        public override void SendBackMsg(string str,string sender)
        {
            pda.Send("to:" + sender + ":" + str);
        }

        public override void SendBackCMDList()
        {
            //pda.Send("hash:" + comingNumber + ":" + this.GetCMDList());
        }
    }
}
